package com.xin.di.uav.applet.controller;

import com.xin.di.uav.applet.service.NewUserService;
import com.xin.di.uav.common.response.login.LoginResponse;
import com.xin.di.uav.common.utils.Rs;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.constraints.NotBlank;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author LTQ
 * 登录
 */
@Api(tags = "登录")
@RestController
@RequestMapping("/sys/")
@Validated
public class LoginController {

    @Autowired
    private NewUserService newUserService;

    @Operation(tags = "通过密码登录", description = "通过密码登录")
    @GetMapping("login-by-password")
    public Rs<String> loginByCode(@RequestParam @NotBlank(message = "用户名不能为空") String userName, @RequestParam @NotBlank(message = "密码不能为空") String password) {
        return Rs.success(newUserService.loginByCode(userName, password));
    }

}
